<template>
  <div class="hospital">
    <!-- 左侧导航区域 -->
    <div class="menu">
      <div class="top">
        <el-icon>
          <HomeFilled />
        </el-icon>
        <span> 医院信息</span>
      </div>
      <el-menu :default-active="$route.path" class="el-menu-vertical-demo" router>
        <el-menu-item index="/hospitaldetails/register" @click="changeActive('/hospitaldetails/register')">
          <el-icon><icon-menu /></el-icon>
          <span>预约挂号</span>
        </el-menu-item>
        <el-menu-item index="/hospitaldetails/detail" @click="changeActive('/hospitaldetails/detail')">
          <el-icon>
            <document />
          </el-icon>
          <span>医院详情</span>
        </el-menu-item>
        <el-menu-item index="/hospitaldetails/notice" @click="changeActive('/hospitaldetails/notice')">
          <el-icon>
            <Message />
          </el-icon>
          <span>预约须知</span>
        </el-menu-item>
        <el-menu-item index="/hospitaldetails/close" @click="changeActive('/hospitaldetails/close')">
          <el-icon>
            <InfoFilled />
          </el-icon>
          <span>停诊信息</span>
        </el-menu-item>
        <el-menu-item index="/hospitaldetails/search" @click="changeActive('/hospitaldetails/search')">
          <el-icon>
            <Search />
          </el-icon>
          <span>查询/取消</span>
        </el-menu-item>
      </el-menu>
    </div>
    <!-- 右侧内容展示区域：路由组件展示位置 -->
    <div class="content">
      <!-- 子组件展示结构的地方 -->
      <router-view></router-view>
    </div>
  </div>
</template>
  
<script setup lang="ts">
// 左侧菜单图标
import {
  Document,
  HomeFilled,
  Menu as IconMenu,
  InfoFilled,
  Search,
  Message,
} from "@element-plus/icons-vue";
import { onMounted } from "vue";
import useDetailStore from '@/store/modules/hosptialDetail'
import { useRoute, useRouter } from "vue-router";
//获取仓库对象
const detailStore = useDetailStore();
// 获取当前的路由信息
const $route = useRoute();
// 获取路由器
let $router = useRouter();
// 左侧菜单点击事件回调
const changeActive = (path: string) => {
  const query=localStorage.getItem("query")
  // 跳转到对应的二级路由
  $router.push({ path, query: { hoscode: query } });
};
onMounted(() => {
  //获取医院详情数据
  detailStore.getHospital($route.query.hoscode as string)
  //获取医院科室数据
  detailStore.getDepartment($route.query.hoscode as string)
})
</script>
  
<style scoped lang="less">
.hospital {
  display: flex;

  .menu {
    /* menu占两份，另外一个占8份 */
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;

    .top {
      color: #7f7f7f;
      margin-bottom: 10px;
    }
  }

  .content {
    flex: 8;
  }
}
</style>